﻿using System;

namespace Bricks.Caching
{

    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="TCache"></typeparam>
    public abstract class CacheFacadeBase<TCache> : FacadeBase<TCache>, ICacheFacade
    {

        /// <summary>
        /// 
        /// </summary>
        /// <param name="cacheAccessor"></param>
        protected CacheFacadeBase(Func<TCache> cacheAccessor) :
            base(cacheAccessor)
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public object this[string key]
        {
            get { return Get(key); }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public abstract void Add(string key, object value);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public abstract bool Contains(string key);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public abstract object Get(string key);

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="TValue"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        public TValue Get<TValue>(string key)
        {
            return (TValue)Get(key);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        public abstract void Remove(string key);

        /// <summary>
        /// 
        /// </summary>
        public abstract void Flush();
    }
}
